﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DECOR.BL.BE;
using DECOR.BL.BC;
using System.IO;

namespace DECOR.WebApp
{
    public partial class getImage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string ImgID = Request.QueryString["ID"].ToString();
            if (!string.IsNullOrEmpty(ImgID))
            {
                byte[] byteArray;
                string urlimg = ParametroBC.Instance.getParamValue("ImgUrl") + ImgID + "." + ParametroBC.Instance.getParamValue("ImgExt");
                if (!File.Exists(urlimg))
                {
                    urlimg = ParametroBC.Instance.getParamValue("ImgDef");
                }
                byteArray = File.ReadAllBytes(urlimg);
                
                Response.Clear();
                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(byteArray);
            }
        }
    }
}
